package com.itcm.cloudStudy.service.impl;

import com.itcm.cloudStudy.service.MsgProvider;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * 描述:
 *
 * @author cm_fighting
 * @create 2020-08-13 4:48 下午
 */
@EnableBinding(Source.class)    // 定义消息的推送管道
public class MsgProviderImpl implements MsgProvider {

    @Resource
    private MessageChannel output;  // 消息发送管道

    @Override
    public void send() {
        String serial = UUID.randomUUID().toString();
        output.send(MessageBuilder.withPayload(serial).build());
        System.out.println("******** " + serial);
    }
}
